from itertools import accumulate

# 请在此输入您的代码
n, k = map(int, input().split())
nums = []
for _ in range(n):
    nums.append(int(input()))
prefix = [0] + list(accumulate(nums))
# 每种求余
kinds = [0] * k
for i, val in enumerate(prefix):
    kinds[val % k] += 1
result = 0
for t in kinds:
    result += t * (t - 1) // 2
print(result)
